Skip to content

Exo2 2 #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: thibault
Choose a base branch
from
Open

Exo2 2 #11

wants to merge 2 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Dec 5, 2020

No description provided.

Copy link
Owner

@pymaldebaran pymaldebaran left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ton algo est top et très clair. Il n'y a quasi rien à changer, juste des détails, important, mais des détails.



def crack_key(cypher_text: str) -> int:
"""Finde key"""
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On va essayer d'éméliorer cette docstring... elle est pas là juste pour décorer !

"""Finde key"""
ALPHABET = list(string.ascii_uppercase)
CYPHER_TEXT = list(cypher_text)
list_occurence_by_letter = []
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On évite généralement de mettre le type d'une variable dans son nom (car souvent au cours de la vie d'un code, on change les types !)

CYPHER_TEXT = list(cypher_text)
list_occurence_by_letter = []
for letter in ALPHABET:
occurrence = CYPHER_TEXT.count(letter)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Très bonne idée d'utiliser count 👍

INDEX_LETTER_MOST_OCCURENCE = list_occurence_by_letter.index(
max(list_occurence_by_letter)
)
LIKELY_TO_BE_E = ALPHABET[INDEX_LETTER_MOST_OCCURENCE]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cette ligne est super belle 👍



def do_decipher(cypher_text: str, key: int) -> str:
"""Decipher text """
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comme pour l'autre fonction : il faudrait améliorer cette docstring. Genre au moins dire qu'onle fait avec la clé...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant